package com.homework.T6;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @author xiyu
 * @version 1.0
 * @date 2025/4/2 18:48
 * @description
 */
public class Test {
    public static void main(String[] args) {
        HashMap<String,String> teachers = new HashMap<>();
        teachers.put("Tom","CoreJava");
        teachers.put("John","Oracle");
        teachers.put("Susan","Oracle");
        teachers.put("Jerry","JDBC");
        teachers.put("Jim","Unix");
        teachers.put("Kevin","JSP");
        teachers.put("Lucy","JSP");

        teachers.put("Allen","JDBC");

        Set<String> namekey = teachers.keySet();
        for (String s : namekey) {
            if (s.equals("Lucy")){
                teachers.put(s,"CoreJava");
            }
        }

        for (String s : namekey) {
            System.out.println(s+":"+teachers.get(s));
        }
        System.out.println("--------------------------");
        Set<Map.Entry<String, String>> entries = teachers.entrySet();
        System.out.println("教JSP的老师有：");
        for (Map.Entry<String, String> entry : entries) {
            if (entry.getValue().equals("JSP")){
                System.out.println(entry.getKey());
            }
        }
    }
}
